﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="InspectionSetting.aspx.cs" Inherits="InspectionSetting" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>巡检表设置</title>
    <link href="../css/ExtStyle.css" rel="stylesheet" type="text/css" />
    <link href="../js/plugins/layer/skin/layer.css" rel="stylesheet" />
    <link href="../js/plugins/layer/skin/layer.ext.css" rel="stylesheet" />
    <script src="../js/jquery/jquery-3.2.1.min.js" type="text/javascript"></script>
    <script src="../js/plugins/layer/layer.min.js" type="text/javascript"></script>

    <style type="text/css">

        .cyl_header { padding: 0px 0px 0px 0px; }

        .cyl_header p { font-size : 2em; }

        .cyl_table {margin-top:3px; width : 100% !important; }

        .cyl_table1 {margin-bottom:5px;}

        .cyl_tr {height:30px !important;}

        .cyl_tr_td {background-color:#C0C0C0;}

        .cyl_span1 {
            cursor: pointer;
            right:1px; 
            float: right; 
            height:25px; 
            width:615px;
        }

        .cyl_span2 {
            right:1px; 
            float: right; 
            height:24px; 
            width:24px;
        }

    </style>
    <script type="text/javascript">
        
        //创建时的移除行
        var addTableData = new Array();
        function AddRemove_Row(pIndex, index)
        {
            
            var objTable = document.getElementById("addTable" + pIndex);
            var length = objTable.rows.length - 1;

            var cId = document.getElementById("imgAddDel" + pIndex + index).alt;
            if (cId == 0) {
                GetAddData(pIndex, index);
                for (var j = 1; j < length; j++) {
                    var countRow = objTable.rows.length;
                    if (countRow > 2) {
                        objTable.deleteRow(1);
                    }
                }
                BindAddData(pIndex);
                ComputeScore(pIndex, index);
            }
            else {
                Ext.MessageBox.confirm("提示", "确定要删除此检查项目？删除后不能在查出！", function (yesno) {
                    SevaDelOne(yesno, pIndex, index);
                });
            }
        }

        //移除表格里的所有行
        function AddRemove_AllRow(pIndex)
        {
            document.getElementById("txtAddLongName" + pIndex).value = "";
            document.getElementById("txtAddShortName" + pIndex).value = "";
            document.getElementById("txtAddTotal" + pIndex).value = 0;
            var objTable = document.getElementById("addTable" + pIndex);
            var length = objTable.rows.length - 1;
            for (var j = 1; j < length; j++) {
                var countRow = objTable.rows.length;
                if (countRow > 2) {
                    objTable.deleteRow(1);
                }
            }
        }

        //标记子项名称是否为空或占比是否有为零
        var IsScoreZero = false;
        //获取创建时的表格数据
        function GetAddData(pIndex, index)
        {
            var objTable = document.getElementById("addTable" + pIndex);
            var length = objTable.rows.length - 1;
            addTableData = [];
            IsScoreZero = false;
            for (var i = 1; i < length; i++) {
                if (i != index) {
                    var txtAddDes = document.getElementById("txtAddDes" + pIndex + i).value;
                    var txtAddScore = document.getElementById("txtAddScore" + pIndex + i).value;
                    var txtAddMagDes = document.getElementById("txtAddMagDes" + pIndex + i).value;
                    var selAddDegree = document.getElementById("selAddDegree" + pIndex + i).value;
                    var imgAddState = document.getElementById("imgAddState" + pIndex + i).alt;
                    var imgAddDel = document.getElementById("imgAddDel" + pIndex + i).alt;

                    if (txtAddDes == "" || txtAddScore == 0)
                    {
                        IsScoreZero = true;
                    }

                    var item = { "cId": imgAddDel, "Des": txtAddDes, "MagDes": txtAddMagDes, "Score": txtAddScore, "Degree": selAddDegree, "State": imgAddState };
                    addTableData.push(item);
                }
            }
            //console.log(addTableData);
        }

        //创建时重新画表格
        function BindAddData(pIndex)
        {
            var objTable = document.getElementById("addTable" + pIndex);
            for (var index = 1; index < addTableData.length + 1; index++) {
                var nextRow = objTable.insertRow(index);
                var str_td = "<td style=\"text-align:center\">" + index + "</td>";
                str_td = str_td + "<td><input id=\"txtAddDes" + pIndex + index + "\" type=\"text\" style=\"width:100%; height:30px; border:none; outline:medium;\" maxlength=\"500\" /></td>";
                str_td = str_td + "<td><input id=\"txtAddMagDes" + pIndex + index + "\" type=\"text\" style=\"width:100%; height:30px; border:none; outline:medium;\" maxlength=\"500\" /></td>";
                str_td = str_td + "<td><input id=\"txtAddScore" + pIndex + index + "\" type=\"text\" style=\"width:100%; height:30px; text-align:center; border:none; outline:medium;\" onkeyup=\"clearNoNum(this,'" + pIndex + "'," + index + ");\" /></td>";
                str_td = str_td + "<td><select id=\"selAddDegree" + pIndex + index + "\" style=\"width:100%; height:30px; border:none; outline:medium;\"><option value=\"1\">正常</option><option value=\"2\">重要</option></select></td>";
                str_td = str_td + "<td style=\"text-align:center\"><img id=\"imgAddState" + pIndex + index + "\" alt=\"1\" src=\"../images/state1.png\" style=\"cursor: pointer;\" onclick=\"IsState('" + pIndex + "'," + index + ");\" /></td>";
                str_td = str_td + "<td style=\"border:none;\"><img id=\"imgAddDel" + pIndex + index + "\" alt=\"0\" src=\"../images/u14515.png\" style=\"cursor: pointer;\" onclick=\"AddRemove_Row('" + pIndex + "'," + index + ");\" /></td>";
                nextRow.innerHTML = str_td;
                nextRow.className = "cyl_tr";


                document.getElementById("txtAddDes" + pIndex + index).value = addTableData[index - 1].Des;
                document.getElementById("txtAddMagDes" + pIndex + index).value = addTableData[index - 1].MagDes;
                document.getElementById("txtAddScore" + pIndex + index).value = addTableData[index - 1].Score;
                var option = 0;
                if (addTableData[index - 1].Degree == 2)
                {
                    option = 1;
                }
                else if (addTableData[index - 1].Degree == 1)
                {
                    option = 0;
                }
                document.getElementById("selAddDegree" + pIndex + index).selectedIndex = option;
                document.getElementById("imgAddState" + pIndex + index).alt = addTableData[index - 1].State;
                document.getElementById("imgAddState" + pIndex + index).src = "../images/state" + addTableData[index - 1].State + ".png";
                document.getElementById("imgAddDel" + pIndex + index).alt = addTableData[index - 1].cId;
            }
        }

        //创建父巡检中的子类
        function AddAdd_Row(pIndex)
        {
            var objTable = document.getElementById("addTable" + pIndex);
            var index = objTable.rows.length - 1;
            var nextRow = objTable.insertRow(index);

            var str_td = "<td style=\"text-align:center\">" + index + "</td>";
            str_td = str_td + "<td><input id=\"txtAddDes" + pIndex + index + "\" type=\"text\" style=\"width:100%; height:30px; border:none; outline:medium;\" maxlength=\"500\" /></td>";
            str_td = str_td + "<td><input id=\"txtAddMagDes" + pIndex + index + "\" type=\"text\" style=\"width:100%; height:30px; border:none; outline:medium;\" maxlength=\"500\" /></td>";
            str_td = str_td + "<td><input id=\"txtAddScore" + pIndex + index + "\" type=\"text\" value=\"0\" style=\"width:100%; height:30px; text-align:center; border:none; outline:medium;\" onkeyup=\"clearNoNum(this,'" + pIndex + "'," + index + ");\" /></td>";
            str_td = str_td + "<td><select id=\"selAddDegree" + pIndex + index + "\" style=\"width:100%; height:30px; border:none; outline:medium;\"><option value=\"1\">正常</option><option value=\"2\">重要</option></select></td>";
            str_td = str_td + "<td style=\"text-align:center\"><img id=\"imgAddState" + pIndex + index + "\" alt=\"1\" src=\"../images/state1.png\" style=\"cursor: pointer;\" onclick=\"IsState('" + pIndex + "'," + index + ");\" /></td>";
            str_td = str_td + "<td style=\"border:none;\"><img id=\"imgAddDel" + pIndex + index + "\" alt=\"0\" src=\"../images/u14515.png\" style=\"cursor: pointer;\" onclick=\"AddRemove_Row('" + pIndex + "'," + index + ");\" /></td>";

            nextRow.innerHTML = str_td;
            nextRow.className = "cyl_tr";
        }

        //是否有效:默认1-有效 0-无效
        function IsState(pIndex, index)
        {
            var txtCid = document.getElementById("imgAddDel" + pIndex + index).alt;
            if (txtCid == "0") {
                SetState(pIndex, index);
            }
            else {
                //调用接口
                CompanyX.IsProgressRun(txtCid, {
                    success: function (data) {
                        if (data == 1) {
                            Ext.MessageBox.alert("提示", "检查子项正在进行巡检评分中不可禁用！");
                        }
                        else if (data == 0) {
                            SetState(pIndex, index);
                        }
                        else {
                            Ext.net.Notification.show({
                                html: '系统验证失败',
                                title: '提示'
                            });
                        }
                    }
                });
            }
        }

        //设置状态函数cyl2018-03-09
        function SetState(pIndex, index)
        {
            var bgeinState = document.getElementById("imgAddState" + pIndex + index).alt;
            if (bgeinState == 1) {
                bgeinState = 0;
                document.getElementById("imgAddState" + pIndex + index).alt = 0;
                document.getElementById("imgAddState" + pIndex + index).src = "../images/state0.png";
            }
            else {
                bgeinState = 1;
                document.getElementById("imgAddState" + pIndex + index).alt = 1;
                document.getElementById("imgAddState" + pIndex + index).src = "../images/state1.png";
            }

            ComputeScore(pIndex, index);
        }

        //显示隐藏Table
        function ShowHide(pIndex)
        {
            var tabClose = document.getElementById("tabClose" + pIndex);
            if (tabClose.alt == 1) {
                tabClose.alt = 0;
                tabClose.src = "../images/right_u.png";
                $("#addTable" + pIndex).hide();
            }
            else {
                tabClose.alt = 1;
                tabClose.src = "../images/right_d.png";
                $("#addTable" + pIndex).show();
            }
        }

        //验证decimal数值
        function clearNoNum(obj, pIndex, index)
        {
            obj.value = obj.value.replace(/[^\d.]/g, "");  //清除“数字”和“.”以外的字符  
            obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的  
            obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d).*$/, '$1$2.$3');//只能输入两个小数  \d
            if (obj.value.indexOf(".") < 0 && obj.value != "") {//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额 
                obj.value = parseFloat(obj.value);
            }
            if (obj.value == "") {
                obj.value = 0;
            }
            //过滤只能1-10
            if (obj.value < 0 || obj.value > 101) {
                obj.value = 0;
            }
            
            ComputeScore(pIndex, index);
        }

        //计算单项占比分
        function ComputeScore(pIndex, index)
        {
            var objTable = document.getElementById("addTable" + pIndex);
            var length = objTable.rows.length - 1;
            var count = 0;
            for (var i = 1; i < length; i++) {
                var txtAddScore = document.getElementById("txtAddScore" + pIndex + i).value;
                var imgAddState = document.getElementById("imgAddState" + pIndex + i).alt;
                if (imgAddState == 1)
                {
                    count = count + parseFloat(txtAddScore);
                }
            }
            document.getElementById("txtAddTotal" + pIndex).value = count.toFixed(1);
            ComputeTotalScore(pIndex, index)
        }

        //计算总占比分
        function ComputeTotalScore(pIndex, index)
        {
            var totalCount = 0;
            for (var i = 0; i < loadTableCount.length; i++)
            {
                var txtAddTotal = document.getElementById("txtAddTotal" + i).value;
                totalCount = totalCount + parseFloat(txtAddTotal);
            }
            if (pIndex == "a")
            {
                var txtAddTotal = document.getElementById("txtAddTotal" + pIndex).value;
                totalCount = totalCount + parseFloat(txtAddTotal);
            }

            totalCount = totalCount.toFixed(1);

            //计算使用和剩余的占比分
            document.getElementById("cylCountScore").innerHTML = "&nbsp;&nbsp;已设分数：<span style=\"color:red;\">" + totalCount + "</span> 剩余分数：<span style=\"color:green;\">" + (100 - totalCount).toFixed(1) + "</span>";
            if (totalCount > 100)
            {
                Ext.MessageBox.alert("提示", "所有巡检项之合的总比分不能大于100！请重新调整在提交！");
                if (pIndex == "a") { //从算创建时的表格数据
                    var objTable = document.getElementById("addTable" + pIndex);
                    var length = objTable.rows.length - 1;
                    var count = 0;
                    for (var i = 1; i < length; i++) {
                        var txtAddScore = document.getElementById("txtAddScore" + pIndex + i).value;
                        var imgAddState = document.getElementById("imgAddState" + pIndex + i).alt;
                        if (imgAddState == 1) {
                            count = count + parseFloat(txtAddScore);
                        }
                    }
                    var txtAddScore = (count - (totalCount - 100)).toFixed(1);
                    var bolAlt = false;
                    for (var i = 1; i < length; i++) {
                        var imgAddState = document.getElementById("imgAddState" + pIndex + i).alt;
                        if (imgAddState == 1) {
                            if (bolAlt == false) {
                                bolAlt = true;
                                document.getElementById("txtAddScore" + pIndex + i).value = txtAddScore;
                            }
                            else {
                                document.getElementById("txtAddScore" + pIndex + i).value = 0;
                            }
                        }
                        else {
                            document.getElementById("txtAddScore" + pIndex + i).value = 0;
                        }
                    }
                    document.getElementById("txtAddTotal" + pIndex).value = txtAddScore;
                }
                else {
                    var txtAddScore = document.getElementById("txtAddScore" + pIndex + index).value;
                    document.getElementById("txtAddScore" + pIndex + index).value = (txtAddScore - (totalCount - 100)).toFixed(1);
                    ComputeScore(pIndex, index);
                }
                return false;
            }
            return true;
        }

        //判断每个表格的比分是否有修改没保存
        function IsTableNameScoreUp(pIndex)
        {
            for (var i = 0; i < loadTableCount.length; i++) {
                var txtAddTotal = document.getElementById("txtAddTotal" + i).value;
                if (txtAddTotal != loadTableCount[i].pScore)
                {
                    if (pIndex != "a" && pIndex == i.toString())
                    { }
                    else
                    {
                        return "巡检类别：" + loadTableCount[i].lName + " 分数占比以做修改请先保存！";
                    }
                }
            }
            return "";
        }

        //获取创建时的表格数据
        function GetCidItem(pIndex) {
            var objTable = document.getElementById("addTable" + pIndex);
            var length = objTable.rows.length - 1;
            var CidItem = "";
            for (var i = 1; i < length; i++) {
                CidItem = CidItem + document.getElementById("imgAddDel" + pIndex + i).alt + ",";
            }
            return CidItem;
        }

        //====创建、删除、保存====================================================================================
        //创建
        function AddFound(pIndex) {

            var mag = IsTableNameScoreUp(pIndex);
            if (mag == "") {
                var txtSevaLongName = document.getElementById("txtAddLongName" + pIndex).value;
                var txtSevaShortName = document.getElementById("txtAddShortName" + pIndex).value;
                var txtSevaTotal = document.getElementById("txtAddTotal" + pIndex).value;
                if (txtSevaLongName == "" || txtSevaShortName == "" || txtSevaTotal == 0) {
                    Ext.MessageBox.alert("提示", "巡检类别和简称不能为空！分数占比不能为零！");
                }
                else {
                    GetAddData(pIndex, 0);
                    if (IsScoreZero == true) {
                        Ext.MessageBox.alert("提示", "巡检类别:" + txtSevaLongName + " 中不能存在检查项目名称为空 和 分值为零的数据项！");
                    }
                    else {
                        //data:[{ "cId": 4, "Des": "检查项目2", "MagDes": "检查项目说明2", "Score": 40, "Degree": 1, "State": 1 }] 
                        var JsonParams = { "pId": 0, "pCode": "0", "lName": txtSevaLongName, "sName": txtSevaShortName, "pScore": txtSevaTotal, data: addTableData };
                        //调用接口
                        CompanyX.AddFoundRun( JsonParams, {
                            success: function (data) {
                                if (data > 0) {
                                    LoadData();
                                    AddRemove_AllRow("a");
                                    Ext.net.Notification.show({
                                        html: '创建成功',
                                        title: '提示'
                                    });
                                }
                                else {
                                    Ext.net.Notification.show({
                                        html: '创建失败',
                                        title: '提示'
                                    });
                                }
                            }
                        });
                    }
                }
            }
            else {
                Ext.MessageBox.alert("提示", mag);
            }
        }

        //删除单行
        function SevaDelOne(yesno, pIndex, index)
        {
            if (yesno == "yes")
            {
                var txtPid = document.getElementById("txtPid" + pIndex).value;
                var txtAddTotal = document.getElementById("txtAddTotal" + pIndex).value;
                var txtAddScore = document.getElementById("txtAddScore" + pIndex + index).value;
                var txtCid = document.getElementById("imgAddDel" + pIndex + index).alt;
                var imgAddState = document.getElementById("imgAddState" + pIndex + index).alt;
                if (imgAddState == 1) {
                    txtAddTotal = (txtAddTotal - txtAddScore).toFixed(1);
                }

                var JsonParams = { "pId": txtPid, "cId": txtCid, "pScore": txtAddTotal };
                //调用接口
                CompanyX.SevaDelOneRun(JsonParams, {
                    success: function (data) {
                        if (data == 1) {
                            LoadData();
                            AddRemove_AllRow("a");
                            Ext.net.Notification.show({
                                html: '删除成功',
                                title: '提示'
                            });
                        }
                        else if (data == 2)
                        {
                            Ext.MessageBox.alert("提示", "检查项目以被使用不可删除！");
                        }
                        else {
                            Ext.net.Notification.show({
                                html: '删除失败',
                                title: '提示'
                            });
                        }
                    }
                });
            }
        }

        //删除巡检类别多行
        function SevaDel(pId, pCode, pIndex)
        {
            Ext.MessageBox.confirm("提示", "确定要删除此巡检类别？删除后不能在查出！", function (yesno) {
                if (yesno == "yes") {
                    var CidItem = GetCidItem(pIndex);
                    CidItem = CidItem + pId;
                    var JsonParams = CidItem;
                    //调用接口
                    CompanyX.SevaDelRun(JsonParams, {
                        success: function (data) {
                            if (data == 1) {
                                LoadData();
                                AddRemove_AllRow("a");
                                Ext.net.Notification.show({
                                    html: '删除成功',
                                    title: '提示'
                                });
                            }
                            else if (data == 2) {
                                Ext.MessageBox.alert("提示", "检查项目以被使用不可删除！");
                            }
                            else {
                                Ext.net.Notification.show({
                                    html: '删除失败',
                                    title: '提示'
                                });
                            }
                        }
                    });
                }
            });
        }
        //保存
        function SevaEdit(pId, pCode, pIndex)
        {
            var mag = IsTableNameScoreUp(pIndex);
            if (mag == "") {
                var txtSevaLongName = document.getElementById("txtAddLongName" + pIndex).value;
                var txtSevaShortName = document.getElementById("txtAddShortName" + pIndex).value;
                var txtSevaTotal = document.getElementById("txtAddTotal" + pIndex).value;
                if (txtSevaLongName == "" || txtSevaShortName == "" || txtSevaTotal == 0) {
                    Ext.MessageBox.alert("提示", "巡检类别和简称不能为空！分数占比不能为零！");
                }
                else {
                    GetAddData(pIndex, 0);
                    if (IsScoreZero == true) {
                        Ext.MessageBox.alert("提示", "巡检类别:" + txtSevaLongName + " 中不能存在检查项目名称为空 和 分值为零的数据项！");
                    }
                    else {
                        //data:[{ "cId": 4, "Des": "检查项目2", "MagDes": "检查项目说明2", "Score": 40, "Degree": 1, "State": 1 }] 
                        var JsonParams = { "pId": pId, "pCode": pCode, "lName": txtSevaLongName, "sName": txtSevaShortName, "pScore": txtSevaTotal, data: addTableData };
                        //调用接口
                        CompanyX.SevaEditRun(JsonParams, {
                            success: function (data) {
                                if (data > 0) {
                                    LoadData();
                                    AddRemove_AllRow("a");
                                    Ext.net.Notification.show({
                                        html: '保存成功',
                                        title: '提示'
                                    });
                                }
                                else {
                                    Ext.net.Notification.show({
                                        html: '保存失败',
                                        title: '提示'
                                    });
                                }
                            }
                        });
                    }
                }
            }
            else {
                Ext.MessageBox.alert("提示", mag);
            }
        }

        var loadTableCount = new Array(); //获取部分加载创建的表格数据
        function LoadData()
        {
            try {
                //var loadTableData = [{ "pId": 1, "pCode": "TT001", "lName": "长名称", "sName": "短名称", "pScore": 50, data: [{ "cId": 2, "Des": "检查项目1", "MagDes": "检查项目说明1", "Score": 50, "Degree": 2, "State": 1 }] }];
                //var loadTableData1 = { "pId": 3, "pCode": "TT002", "lName": "长名称1", "sName": "短名称1", "pScore": 40, data: [{ "cId": 4, "Des": "检查项目2", "MagDes": "检查项目说明2", "Score": 40, "Degree": 1, "State": 1 }] };
                //loadTableData.push(loadTableData1);

                //调用接口
                CompanyX.LoadDataItem("", {
                    success: function (data) {
                        layer.close(beginLoad);
                        //console.log(data.list[0]);
                        if (data.list[0].pId == 0) {
                            Ext.net.Notification.show({
                                html: '没有数据',
                                title: '提示'
                            });
                        }
                        else {
                            var loadTableData = data.list;

                            var objDiv = document.getElementById("cylDiv1");
                            var cylDiv1Html = "";
                            objDiv.innerHTML = cylDiv1Html;
                            loadTableCount = [];
                            for (var i = 0; i < loadTableData.length; i++) {
                                cylDiv1Html = cylDiv1Html + "<table class=\"cyl_table\">";
                                cylDiv1Html = cylDiv1Html + "<tr class=\"cyl_tr_td\">";
                                cylDiv1Html = cylDiv1Html + "<td>";
                                cylDiv1Html = cylDiv1Html + "&nbsp;<input type=\"button\" value=\"删除\" onclick=\"SevaDel(" + loadTableData[i].pId + ", '" + loadTableData[i].pCode + "'," + i + ");\" />&nbsp;";
                                cylDiv1Html = cylDiv1Html + "<input type=\"button\" value=\"保存\" onclick=\"SevaEdit(" + loadTableData[i].pId + ", '" + loadTableData[i].pCode + "'," + i + ");\" />";
                                cylDiv1Html = cylDiv1Html + "<span class=\"cyl_span1\" onclick=\"ShowHide('" + i + "');\"><img id=\"tabClose" + i + "\" class=\"cyl_span2\" alt=\"1\" src=\"../images/right_d.png\" /></span>";
                                cylDiv1Html = cylDiv1Html + "<input id=\"txtPid" + i + "\" type=\"text\" value=\"" + loadTableData[i].pId + "\" style=\"display:none;\" />";
                                cylDiv1Html = cylDiv1Html + "</td>";
                                cylDiv1Html = cylDiv1Html + "</tr>";

                                cylDiv1Html = cylDiv1Html + "<tr><td>";
                                cylDiv1Html = cylDiv1Html + "<table class=\"cyl_table\"><tr>";
                                cylDiv1Html = cylDiv1Html + "<td style=\"width:70px;\">巡检类别：</td>";
                                cylDiv1Html = cylDiv1Html + "<td style=\"width:180px;\"><input id=\"txtAddLongName" + i + "\" type=\"text\" maxlength=\"10\" /></td>";
                                cylDiv1Html = cylDiv1Html + "<td style=\"width:44px;\">简称：</td>";
                                cylDiv1Html = cylDiv1Html + "<td style=\"width:180px;\"><input id=\"txtAddShortName" + i + "\" type=\"text\" maxlength=\"4\" /></td>";
                                cylDiv1Html = cylDiv1Html + "<td style=\"width:70px;\">分数占比：</td>";
                                cylDiv1Html = cylDiv1Html + "<td><input id=\"txtAddTotal" + i + "\" type=\"text\" readonly=\"readonly\" style=\"color:red; border:none; outline:medium;\" value=\"0\" /></td>";
                                cylDiv1Html = cylDiv1Html + "<tb></tb>";
                                cylDiv1Html = cylDiv1Html + "</tr></table>";
                                cylDiv1Html = cylDiv1Html + "</td></tr>";

                                cylDiv1Html = cylDiv1Html + "<tr><td>";
                                cylDiv1Html = cylDiv1Html + "<table id=\"addTable" + i + "\" class=\"cyl_table cyl_table1\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" style=\"border:none;\">";
                                cylDiv1Html = cylDiv1Html + "<tr class=\"cyl_tr\">";
                                cylDiv1Html = cylDiv1Html + "<td class=\"cyl_tr_td\" style=\"width:4%; text-align:center\">序号</td>";
                                cylDiv1Html = cylDiv1Html + "<td class=\"cyl_tr_td\" style=\"width:40%; text-align:center\">检查项目</td>";
                                cylDiv1Html = cylDiv1Html + "<td class=\"cyl_tr_td\" style=\"width:28%; text-align:center\">检查项目说明</td>";
                                cylDiv1Html = cylDiv1Html + "<td class=\"cyl_tr_td\" style=\"width:8%; text-align:center\">分值</td>";
                                cylDiv1Html = cylDiv1Html + "<td class=\"cyl_tr_td\" style=\"width:8%; text-align:center\">重要程度</td>";
                                cylDiv1Html = cylDiv1Html + "<td class=\"cyl_tr_td\" style=\"width:8%; text-align:center\">标识</td>";
                                cylDiv1Html = cylDiv1Html + "<td style=\"border:none; width:4%;\"></td>";
                                cylDiv1Html = cylDiv1Html + "</tr>";
                                cylDiv1Html = cylDiv1Html + "<tr class=\"cyl_tr\">";
                                cylDiv1Html = cylDiv1Html + "<td style=\"text-align:center\">+</td><td></td><td></td><td></td><td></td><td></td>";
                                cylDiv1Html = cylDiv1Html + "<td style=\"border:none;\"><img alt=\"添加\" src=\"../images/u14516.png\" style=\"cursor: pointer;\" onclick=\"AddAdd_Row('" + i + "');\" /></td>";
                                cylDiv1Html = cylDiv1Html + "</tr>";
                                cylDiv1Html = cylDiv1Html + "</table>";
                                cylDiv1Html = cylDiv1Html + "</td></tr>";
                                cylDiv1Html = cylDiv1Html + "</table>";

                            }
                            objDiv.innerHTML = cylDiv1Html;
                            var totalCount = 0.0;
                            for (var i = 0; i < loadTableData.length; i++) {
                                document.getElementById("txtAddLongName" + i).value = loadTableData[i].lName;
                                document.getElementById("txtAddShortName" + i).value = loadTableData[i].sName;
                                document.getElementById("txtAddTotal" + i).value = loadTableData[i].pScore;
                                totalCount = totalCount + loadTableData[i].pScore;
                                var NameScoreItem = { "lName": loadTableData[i].lName, "pScore": loadTableData[i].pScore };
                                loadTableCount.push(NameScoreItem);//用于监测表格总比分是否修改
                                addTableData = loadTableData[i].data;
                                BindAddData(i);
                            }
                            //计算使用和剩余的占比分
                            document.getElementById("cylCountScore").innerHTML = "&nbsp;&nbsp;已设分数：<span style=\"color:red;\">" + totalCount.toFixed(1) + "</span> 剩余分数：<span style=\"color:green;\">" + (100 - totalCount).toFixed(1) + "</span>";
                        }
                    }
                });
            }
            catch (e) {
                layer.close(beginLoad);
            }
        }

        var beginLoad = null;
        //页面加载运行
        $(function () {
            //LoadData();
            beginLoad = layer.load(0,
                {
                    shade: [0.2, '#fff'] //0.1透明度的白色背景
                });
            setTimeout("LoadData()", 5000);
        });

    </script>
</head>
<body>
    <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Neptune" />
    <ext:Viewport ID="Viewport1" runat="server">
        <LayoutConfig>
            <ext:HBoxLayoutConfig Align="Stretch" />
        </LayoutConfig>
        <Defaults>
            <ext:Parameter Name="margin" Value="2 0" Mode="Value" />
        </Defaults>
        <Items>
            <ext:TabPanel ID="TabPanel1" runat="server" Flex="1">
                <TopBar>
                    <ext:Toolbar ID="Toolbar2" runat="server" Layout="VBoxLayout" Width="2000" Height="70">
                        <Items>
                            <ext:Panel runat="server">
                                <Content>
                                    <div class="cyl_header">
                                        <p>KM终端督导巡店检查表</p>
                                        <div id="cylCountScore" style="width:196px; height:27px; line-height:27px; position: fixed; right:20px; top:87px;">
                                            &nbsp;&nbsp;已设分数：<span style="color:red;">80</span> 剩余分数：<span style="color:green;">20</span>
                                        </div>
                                    </div>
                                    
                                </Content>
                            </ext:Panel>
                        </Items>
                    </ext:Toolbar>

                </TopBar>
                <Items>
                    <ext:Panel runat="server" Title="巡检表设置" AutoScroll="true" Layout="FitLayout" Height="500">
                        <Items>
                            <ext:Panel runat="server" AutoScroll="true">
                                <Content>
                                    <div style="height:100%">
                                        <div id="cylDiv1">
                                             <%--<table class="cyl_table">
                                                <tr class="cyl_tr_td">
                                                    <td>
                                                        &nbsp;<input type="button" value="删除" onclick="SevaDel(1, 'TT001',0);" />&nbsp;
                                                        <input type="button" value="保存" onclick="SevaEdit(1, 'TT001', 0);" />
                                                        <span class="cyl_span1" onclick="ShowHide('0');">
                                                            <img id="tabClose0" class="cyl_span2" alt="1" src="../images/right_d.png" />
                                                        </span>
                                                        <input id="txtPid0" type="text" value="0" style="display:none;" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <table class="cyl_table">
                                                            <tr>
                                                                <td style="width:70px;">巡检类别：</td>
                                                                <td style="width:180px;">
                                                                    <input id="txtAddLongName0" type="text" maxlength="10" />
                                                                </td>
                                                                <td style="width:44px;">简称：</td>
                                                                <td style="width:180px;">
                                                                    <input id="txtAddShortName0" type="text" maxlength="4" />
                                                                </td>
                                                                <td style="width:70px;">分数占比：</td>
                                                                <td>
                                                                    <input id="txtAddTotal0" type="text" style="color:red; border:none; outline:medium;" value="0" />
                                                                </td>
                                                                <tb></tb>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <table id="addTable0" class="cyl_table cyl_table1" border="1" cellpadding="0" cellspacing="0" style="border:none;">
                                                            <tr class="cyl_tr">
                                                                <td class="cyl_tr_td" style="width:4%; text-align:center">序号</td>
                                                                <td class="cyl_tr_td" style="width:40%; text-align:center">检查项目</td>
                                                                <td class="cyl_tr_td" style="width:28%; text-align:center">检查项目说明</td>
                                                                <td class="cyl_tr_td" style="width:8%; text-align:center">分值</td>
                                                                <td class="cyl_tr_td" style="width:8%; text-align:center">重要程度</td>
                                                                <td class="cyl_tr_td" style="width:8%; text-align:center">标识</td>
                                                                <td style="border:none; width:4%;"></td>
                                                            </tr>

                                                            <tr class="cyl_tr">
                                                                <td style="text-align:center">1</td>
                                                                <td>
                                                                    <input id="txtAddDes01" type="text" style="width:100%; height:30px;" maxlength="500" />
                                                                </td>
                                                                <td>
                                                                    <input id="txtAddMagDes01" type="text" style="width:100%; height:30px;" maxlength="500" />
                                                                </td>
                                                                <td>
                                                                    <input id="txtAddScore01" type="text" style="width:100%; height:30px; text-align:center;" />
                                                                </td>
                                                                <td>
                                                                    <select id="selAddDegree01" style="width:100%; height:30px;">
                                                                        <option value="1">正常</option>
                                                                        <option value="2">重要</option>
                                                                    </select>
                                                                </td>
                                                                <td style="text-align:center">
                                                                    <img id="imgAddState01" alt="1" src="../images/state1.png" style="cursor: pointer;" onclick="IsState('0',1);" />
                                                                </td>
                                                                <td style="border:none;">
                                                                    <img id="imgAddDel01" alt="0" src="../images/u14515.png" style="cursor: pointer;" onclick="AddRemove_Row('0',1);" />
                                                                </td>
                                                            </tr>

                                                            <tr class="cyl_tr">
                                                                <td style="text-align:center">+</td>
                                                                <td></td>
                                                                <td></td>
                                                                <td></td>
                                                                <td></td>
                                                                <td></td>
                                                                <td style="border:none;">
                                                                    <img alt="添加" src="../images/u14516.png" style="cursor: pointer;" onclick="AddAdd_Row('0');" />
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>--%>
                                        </div>
                                        <div id="cylDiv2">
                                            <table class="cyl_table">
                                                <tr class="cyl_tr_td">
                                                    <td>
                                                        &nbsp;<input type="button" value="创建" onclick="AddFound('a');" />
                                                        <span class="cyl_span1" onclick="ShowHide('a');">
                                                            <img id="tabClosea" class="cyl_span2" alt="1" src="../images/right_d.png" />
                                                        </span>
                                                        <input id="txtPida" type="text" value="0" style="display:none;" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <table class="cyl_table">
                                                            <tr>
                                                                <td style="width:70px;">巡检类别：</td>
                                                                <td style="width:180px;">
                                                                    <input id="txtAddLongNamea" type="text" maxlength="10" />
                                                                </td>
                                                                <td style="width:44px;">简称：</td>
                                                                <td style="width:180px;">
                                                                    <input id="txtAddShortNamea" type="text" maxlength="4" />
                                                                </td>
                                                                <td style="width:70px;">分数占比：</td>
                                                                <td>
                                                                    <input id="txtAddTotala" type="text" readonly="readonly" style="color:red; border:none; outline:medium;" value="0" />
                                                                </td>
                                                                <tb></tb>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <table id="addTablea" class="cyl_table cyl_table1" border="1" cellpadding="0" cellspacing="0" style="border:none;">
                                                            <tr class="cyl_tr">
                                                                <td class="cyl_tr_td" style="width:4%; text-align:center">序号</td>
                                                                <td class="cyl_tr_td" style="width:40%; text-align:center">检查项目</td>
                                                                <td class="cyl_tr_td" style="width:28%; text-align:center">检查项目说明</td>
                                                                <td class="cyl_tr_td" style="width:8%; text-align:center">分值</td>
                                                                <td class="cyl_tr_td" style="width:8%; text-align:center">重要程度</td>
                                                                <td class="cyl_tr_td" style="width:8%; text-align:center">标识</td>
                                                                <td style="border:none; width:4%;"></td>
                                                            </tr>

                                                            <%--<tr class="cyl_tr">
                                                                <td style="text-align:center">1</td>
                                                                <td>
                                                                    <input id="txtAddDesa1" type="text" style="width:100%; height:30px; border:none; outline:medium;" maxlength="500" />
                                                                </td>
                                                                <td>
                                                                    <input id="txtAddMagDesa1" type="text" style="width:100%; height:30px; border:none; outline:medium;" maxlength="500" />
                                                                </td>
                                                                <td>
                                                                    <input id="txtAddScorea1" type="text" style="width:100%; height:30px; text-align:center; border:none; outline:medium;" />
                                                                </td>
                                                                <td>
                                                                    <select id="selAddDegreea1" style="width:100%; height:30px;">
                                                                        <option value="1">正常</option>
                                                                        <option value="2">重要</option>
                                                                    </select>
                                                                </td>
                                                                <td style="text-align:center">
                                                                    <img id="imgAddStatea1" alt="1" src="../images/state1.png" style="cursor: pointer;" onclick="IsState('a',1);" />
                                                                </td>
                                                                <td style="border:none;">
                                                                    <img id="imgAddDela1" alt="0" src="../images/u14515.png" style="cursor: pointer;" onclick="AddRemove_Row('a',1);" />
                                                                </td>
                                                            </tr>--%>

                                                            <tr class="cyl_tr">
                                                                <td style="text-align:center">+</td>
                                                                <td></td>
                                                                <td></td>
                                                                <td></td>
                                                                <td></td>
                                                                <td></td>
                                                                <td style="border:none;">
                                                                    <img alt="添加" src="../images/u14516.png" style="cursor: pointer;" onclick="AddAdd_Row('a');" />
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="height:80px;"></td>
                                                </tr>
                                            </table>
                                        </div>
                                        
                                    </div>
                                </Content>
                            </ext:Panel>
                        </Items>
                    </ext:Panel>

                </Items>
            </ext:TabPanel>
        </Items>
    </ext:Viewport>
</body>
</html>
